<?php
namespace app\erp_meixingtiyu\controller;

use think\facade\Request;
use app\store\controller\Controller as StoreController;
use app\erp_meixingtiyu\logic\Referee as RefereeLogic;

class Referee extends StoreController
{
  public function list()
  {
    $list = (new RefereeLogic)->getList();
    return $this->renderSuccess($list);
  }

  public function add()
  {
    $params = Request::only([
      'referee_name',
      'post',
      'position',
      'certificate',
      'price',
      'sort',
    ]);

    (new RefereeLogic)->addReferee($params);
    return $this->renderSuccess('添加成功');
  }

  public function edit()
  {
    $params = Request::only([
      'referee_id',
      'referee_name',
      'post',
      'position',
      'certificate',
      'price',
      'sort',
    ]);
    (new RefereeLogic)->editReferee($params);
    return $this->renderSuccess('修改成功');
  }

  public function delete($refereeId)
  {
    (new RefereeLogic)->deleteReferee($refereeId);
    return $this->renderSuccess('删除成功');
  }

  // 获取空闲的裁判（没有选择场地的）
  public function free()
  {
    $list = (new RefereeLogic)->getFreeReferees();
    return $this->renderSuccess($list);
  }
}
